
// Single Order State
OrderState = function(_id) {

    this.ID = _id;
    this.Name = '';
    this.Color = '';
}

OrderState.prototype.AssembleFromJson = function(json) {
    this.Name = json.name.language.text;
	this.ID = json.id;
	this.Color = json.color;
}

OrderState.prototype.Serialize = function() {
    var xml = '';
    
    xml += '<state>';
        xml += '<id>' + this.ID + '</id>';
        xml += '<name>' + this.Name + '</name>';
        xml += '<color>' + this.Color + '</color>';
    xml += '</state>';
    
    return xml;
}

OrderState.prototype.Deserialize = function(xml) {
    this.ID = $("id", xml).html();
    this.Name = $("name", xml).html();
    this.Color = $("color", xml).html();
}

OrderState.prototype.StatusImage = function() {
	var StateImages = [];
	
	StateImages[1] = "images/states/state_awaiting_cheque_payment.png";
	StateImages[2] = "images/states/state_payment_accepted.png";
	StateImages[3] = "images/states/state_shipping_preparation.gif";
	StateImages[4] = "images/states/state_shipped.png";
	StateImages[5] = "images/states/state_delivered.png";
	StateImages[6] = "images/states/state_cancelled.png";
	StateImages[7] = "images/states/state_refund.png";
	StateImages[8] = "images/states/state_payment_error.png";
	StateImages[9] = null;
	StateImages[10] = "images/states/state_awaiting_bank_wire_payment.png";
	StateImages[11] = "images/states/state_awaiting_paypal_payment.png";
	StateImages[12] = null;
	StateImages[13] = "images/states/state_paypal_authorization_accepted.png";
	
	
	if (StateImages[this.ID] != undefined)
		return StateImages[this.ID];
	else
		return "images/icons/icon32.png";

}